#ifndef     __SENSOR_H
#define     __SENSOR_H

#include "../rtos/mutex.h"
#include "../utils/nocopyable.h"

namespace driver {

class Sensor : utils::NoCopyable {

public:
    void init();

    inline bool is_door_close() { return read_u5a(0); }
    inline bool is_elock_close() { return read_u5a(6); }
    bool is_col_checked(uint8_t col);
    bool is_raster();
    bool is_raster2();
    
    bool is_raster_check();

    inline void clear_raster() {
        m_raster_flag = false;
    }

    inline void set_raster() {
        m_raster_flag = true;
    }

private:
    bool read_u5a(uint8_t addr);
    bool read_u1e(uint8_t addr);
    bool read_u2e(uint8_t addr);

private:
    rtos::Mutex m_u5a;
    rtos::Mutex m_u1e_u2e;
    volatile bool m_raster_flag = false;
};

extern Sensor sensor;

}

#endif
